import React, { Component } from 'react';
//import * as data from '../../config/data'
import * as api from '../../config/api.js'
import * as tools from '../../config/tools'
import { Link, withRouter } from 'react-router-dom';
//待预约记录
class Drecord extends Component {
    constructor(args) {
        super();
        this.state={
            waitingOrderList:[],
        }
    }
    componentDidMount() {
        // setTimeout(() => {
        //     window.testPicker.setData(data.testData);
        //     $('body').on('tap', '#pickerYewu', function() {
        //         var _obj = this;
        //         window.testPicker.show(function(items) {
        //             _obj.innerText = items[0].text;
        //         });
        //     });
        // }, 0)
        this.show()
    }
    show(){
        api.selectWaitingOrder().then((data)=>{
            if(data.result==='RC100'){
                this.setState({
                     waitingOrderList:data.waitingOrderList
                })
            }else{
                tools.toast.error(data.result)
            }
        })
    }
    order(item){
        this.props.history.push({
            pathname:"/dregister",
              query:{
                personName:item.personName,
                policyNo:item.policyNo
              }
        })
    }
    render() {
          
        return (
            <div>
             <header className="mui-bar mui-bar-nav">
            <h1 className="mui-title">待预约记录</h1>
        </header>
        <div className="mui-content">
        {this.state.waitingOrderList.map((items,index)=>{
            return(
             <div className="daiyuyue" key={index}>
                <div className="top">
                    <div className="left">保单号</div>
                    <div className="right">{items.policyNo}</div>
                    <div className="left">截止日期</div>
                    <div className="right">{items.noteDate}&nbsp;&nbsp;00:00</div>
                </div>
                {items.list.map((item,index)=>{
                    return(
                     <ul key={index}>
                    <li>
                        <div onClick={()=>this.order(item)} className="daiyuyue-btn" >预约</div>
                        <div className="left">客户姓名</div>
                        <div className="right">{item.personName}</div>
                    </li>
                    <li>
                        <div className="left">体检次数</div>
                        <div className="right">{item.healthChkCount}</div>
                    </li>
                    <li className="mui-input-row">
                        <label>体检信</label>
                        <p id="pickerYewu" className="mui-input-value pr40">查看</p>
                        <p className="mui-icon mui-icon-arrowdown detail_arrow arrow-down"></p>
                    </li>
                </ul>
                )
                })}
               
                
            </div>   
            )   
        })}
                 
           
        </div>
        </div>
        );
    }
}

export default withRouter(Drecord);